//
//  StressModel.swift
//  DaFit
//
//  Created by Paul on 2022/6/11.
//  Copyright © 2022 sylar. All rights reserved.
//

import Foundation
import SQLite
import HandyJSON
import SwiftDate
import MYModule

open class SingleStressModel: NSObject, MYSQLiteTableiabe, SingleSQLite, HandyJSON {
    
    public var adress: String = ""
    
    public var id: Int64 = 0
    
    public var date: Date = Date().sqlDate()
    
   
    public var stress: Int = 0
    

    /// 结束测量时间戳
    public var end: Double = 0
    
    required public override init() {}
    
    
    @discardableResult
    public func updateData() ->Bool {
        
        if stress <= 0 || stress >= 255 {
            return false
        }

        if id == 0 {
            insert()
            return true
        }
        
        update()
        return true
        
    }
    
 
    
}
